package com.powernode.dataservice.service;

import com.powernode.api.pojo.BaseInfo;
import com.powernode.api.service.BaseInfoService;
import com.powernode.dataservice.mapper.BidInfoMapper;
import com.powernode.dataservice.mapper.ProductInfoMapper;
import com.powernode.dataservice.mapper.UserMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;

@DubboService(interfaceClass =BaseInfoService.class,version = "1.0.0")
public class BaseInfoServiceImpl implements BaseInfoService {

    @Autowired
    private BidInfoMapper bidInfoMapper;

    @Autowired
    private ProductInfoMapper productInfoMapper;

    @Autowired
    private UserMapper userMapper;

    @Override
    public BaseInfo queryBaseInfo() {
        BaseInfo baseInfo = new BaseInfo();
        /*获取三个 数据  分别来自  三种不同的*/
        Integer registerUsers = userMapper.selectCountUser();
        BigDecimal avgRate = productInfoMapper.selectAvgRate();
        BigDecimal sumMoney = bidInfoMapper.selectSumMoney();
        baseInfo.setAvgRate(avgRate);
        baseInfo.setRegisterUsers(registerUsers);
        baseInfo.setSumBidMoney(sumMoney);
        return baseInfo;
    }
}
